package com.waterwolf.wolfbot;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.ArrayList;

public class Finder {
	public static void main(String[] args) {
		
		String lookfor = ".Id";
		
		File f = new File("/home/wolf/workspace/RHFCookies/infinject/cookies");
		File[] fs = f.listFiles(new FilenameFilter() {

			@Override
			public boolean accept(File arg0, String arg1) {
				return arg1.endsWith(".java");
			}
			
		});
		
		ArrayList<String> matches = new ArrayList<String>();
		
		for (File fi : fs) {
			try {
				BufferedReader br = new BufferedReader(new FileReader(fi));
				String line;
				int inx = 0;
				while ((line = br.readLine()) != null) {
					if (line.contains(lookfor))
						matches.add(fi.getName() + ": line " + inx);
					inx++;
				}
					
				br.close();
			}
			catch (IOException e) {
				e.printStackTrace();
			}
		}
		
		for (String s : matches) {
			System.out.println(s);
		}
	}
}
